package com.stackfarm.fvcommon.utils;

import java.math.BigInteger;

public class MqttTools {
    public static double parseHex(String num) {
        if (num.length() == 4) {
            int ret = Integer.parseInt(num, 16);
            ret = ((ret & 0x8000) > 0) ? (ret - 0x10000) : (ret);
            return (double) ret;
        } else if (num.length() == 0) {
            return 0;
        }
        BigInteger in = new BigInteger(num, 16);
        return in.doubleValue();
    }
}
